import TileLayer from "ol/layer/Tile"
import TileArcGISRest from 'ol/source/TileArcGISRest'
import OSM from "ol/source/OSM"
import XYZ from 'ol/source/XYZ'

let maptype=3         //0表示部署的离线瓦片地图，1表示OSM,2表示使用Arcgis在线午夜蓝地图服务

var streetmap=function(){
    var maplayer=null;
    switch(maptype){
        case 0:
            maplayer=[new TileLayer({
                source: new XYZ({
                    url:'http://127.0.0.1:7080/streetmap/shenzhen/{z}/{x}/{y}.jpg'
                })
            })]
        break;
        case 1:
            maplayer=[new TileLayer({
                source: new OSM()
            })]
        break;
        case 2:
            maplayer=[new TileLayer({
                source:new TileArcGISRest({
                    url:'https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer'
                })
            })]
        break;
        case 3:
            maplayer = [
                new TileLayer({
                    source: new XYZ({
                      url:
                        "http://t2.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=c6b38ec0b71ad168e94541ebeccb45b8"
                    })
                  }),
                  new TileLayer({
                        source: new XYZ({
                            url:
                              "http://t2.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=c6b38ec0b71ad168e94541ebeccb45b8"
                          }),
                          isGroup: true,
                          name: "天地图文字标注"
                        })
            ]
            break;
    }
    return maplayer;
}

var mapconfig={
    x:108.94042968750001,     //中心点经度和纬度 117.1121,34.0021
    y:34.275375297643876,
    center: [13036859.337730933,4029084.0083124787],
    zoom: 9,          //地图缩放级别
    maxZoom: 18,
    streetmap:streetmap
};

export default mapconfig
